package com.admission.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.admission.dao.CollegeNoticeDao;
import com.admission.model.CollegeNotice;
import com.admission.util.CollegeDetailTips;

@Repository
@Transactional
public class CollegeNoticeManager {
	private CollegeNoticeDao collegeNoticeDao;

	/**
	 * 通过type寻找唯一对象
	 * 
	 * @param type
	 * @return
	 */
	public CollegeNotice getByType(String type) {
		return collegeNoticeDao.findUniqueBy("type", type);
	}

	/**
	 * 保存
	 * 
	 * @param Entity
	 * @return
	 */
	public void save(CollegeNotice entity) throws Exception {

		CollegeDetailTips.setNoticeTipes(entity.getContent(), entity.getType());
		CollegeDetailTips.setSpecialTips(entity.getNote(), entity.getType());

		collegeNoticeDao.save(entity);
	}

	public CollegeNoticeDao getCollegeNoticeDao() {
		return collegeNoticeDao;
	}

	@Autowired
	public void setCollegeNoticeDao(CollegeNoticeDao collegeNoticeDao) {
		this.collegeNoticeDao = collegeNoticeDao;
	}

}
